<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ include file="/parameter.jsp" %>
<%@ include file="/pageParam.jsp" %>
<%@page isELIgnored="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<TITLE>论坛</TITLE>
<%@ include file="/pageParam.jsp" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<Meta http-equiv="Pragma" Content="No-cach">
<link href="style/style.css" rel="stylesheet" type="text/css" />
<script language="JavaScript">     
	window.onload = function(){
		if(document.getElementById('fckcontent') != null){
     	var oFCKeditor = new FCKeditor('fckcontent') ;
		//debugger;
      	oFCKeditor.BasePath = '${pageContext.request.contextPath}/FCKeditor/' ;
     	oFCKeditor.ToolbarSet = 'Basic' ;
     	oFCKeditor.Height = '300' ;
     	oFCKeditor.ReplaceTextarea();
		}
	 }
function checkRespons()
{
	if(document.form1.title.value==""){
		alert("回复主题不能为空！");
		form1.title.focus();
		return false;
		/*
	}else if(document.form1.content.value==""){
		alert("回复内容不能为空！");
		form1.content.focus();
		return false;
		*/
	}else{
		return document.forms["form1"].submit();
	}
}
function loginsubmit(){
	return document.forms["form1"].submit();
}
function loginsubmitc(){
	return document.forms["form5"].submit();
}
function OperatePost(type,tid,rid){
	var rtnstate= window.confirm("是否确定删除帖子？/r/n单击'确定'继续。单击'取消'停止。");
	if(rtnstate){
		document.frames["hidden1"].location = "commonAction.do?method=CherkIsDelPost&tid=" + tid + "&rid=" + rid;
	}
}
function cherkPost(delState,type,tid,rid){
	if(delState > 0){
		alert("帖子已经有回复信息，没有权限不能删除，请联系版主或管理员进行操作。");
	}else{
		document.forms["form1"].action = "commonAction.do?method=DelPost&type=" + type + "&tid=" + tid + "&rid=" + rid;
		document.forms["form1"].submit();
	}
}
function SearchSubmit(){
	if(doucment.getElementById('keywords').value == ""){
		alert("请输入搜索关键字！");
		return false;
	}else{
		return document.forms["form3"].submit();
	}
}
function SetEssence(tid,act)
{
	//var act = eval("document.getElementById('state" + num + "')");
	location = "commonAction.do?method=SetEssence&tid="+ tid +"&essence="+ act.value;
}
function SetState(tid,act)
{
	//var act = eval("document.getElementById('state" + num + "')");
	location = "commonAction.do?method=SetTopicState&tid="+ tid +"&state="+ act.value;
}
function submitit(){
	//if(form2.paramboard.value == "topic"){
		if(form2.title.value == ""){
			alert("标题不能为空！请填写标题！");
			form2.title.focus();
			return false;
		}
	//}
	if(form2.content.value == ""){
		var fck = FCKeditorAPI.GetInstance("fckcontent"); 
        var content = fck.GetXHTML(true);
        if (content.replace('/<(?!img|input|object)[^>]*>|/s+/ig', "") == "") {
    		alert("内容不能为空！请填写内容！");
            fck.Focus();
            return false;
        }
	}
	return form2.submit();
}
function MoveTo(tid,act)
{
	if(window.confirm("是否确定移动帖子？\r\n移动帖子同时也会移动该帖子的所有回复信息。\r\n单击'确定'继续。单击'取消'停止。")){
		location = "commonAction.do?method=MoveToBoard&tid="+ tid +"&bid="+ act.value;
	}
}
function DelPost(tid){
	var rtnstate=window.confirm("是否确定删除帖子？\r\n删除帖子同时也会删除该帖子的所有回复信息。\r\n单击'确定'继续。单击'取消'停止。");
	if(rtnstate){
		location = "commonAction.do?method=DelPost&tid=" + tid;
	}
}

var fileIndex = 1;
function addImage()
{
	var pho = '<input type="file" name="attfile'+fileIndex+'" />';
	$('#pho').append('<br />');
	$('#pho').append(pho);
	fileIndex++;
}
</script>
</HEAD>
<body>
<iframe id="hidden1" name="operate" allowtransparency="false" frameborder="0" style="height:0;width:0"></iframe>
<jsp:include page="inc/header.jsp" />
		<header class="entry-header">
			<h1 class="entry-title">
				<span>论坛首页<div id="searchbar">
				<form name="form3" method="post" action="commonAction.do?method=SearchTopic">
					<input type="text" id="keywords" name="keywords" title="搜索"><button onClick="search();">搜索</button>
				</form>
				</div></span>
			</h1>
		</header>
		
		<div id="maindiv">
			<div id="nav">
			<c:choose>
				<c:when test="${sessionScope.user == null}">
					<div>
						<form name="form1" method="post" action="commonAction.do?method=UserLogin">
						账号：<input type="text" name="username"> 密码：<input type="password" name="password"> 
						<button onClick="loginsubmit();">登陆</button> <a href="commonAction.do?method=toRegister">注册新账号</a>
						</form>
					</div>
				</c:when>
				<c:otherwise>
					<div>
					&nbsp;&nbsp;<c:choose><c:when test="${sessionScope.user.nickname != ''}">${sessionScope.user.nickname}</c:when><c:otherwise>${sessionScope.user.username}</c:otherwise></c:choose>&nbsp;你好！<a
							href="commonAction.do?method=Logout">注销</a>&nbsp;|&nbsp;<a
							href="commonAction.do?method=EditUserInfo&uid=${sessionScope.user.id}">修改个人信息</a>&nbsp;|&nbsp;<a
							href="commonAction.do?method=EditUserPwd&uid=${sessionScope.user.id}">修改密码</a>
					</div>
				</c:otherwise>
			</c:choose>
				<a href="commonAction.do?method=index" title="首页">首页</a>
				<span>&gt;</span>
                ${navigation} ${TopicInfo.title}
			</div>
			<div id="board">
				<div class="bm">
					<div id="post_b">
						<div><h1>${TopicInfo.title}</h1></div>
						<div class="post_sub"><span class="post_bar"><a href="#alltopid">所有跟帖</a> | <a href="#revert">回复本帖</a></span><span>作者: <a href="commonAction.do?method=ViewUserInfo&uid=${TopicInfo.postuser.id}">${TopicInfo.postuser.nickname}</a> 发表时间: <fmt:formatDate value="${TopicInfo.date}" type="both"/></span>&nbsp;&nbsp;&nbsp;&nbsp;<c:if test="${TopicInfo.historical != '1'}"><c:if test="${null != sessionScope.user}"><c:if test="${(TopicInfo.postuser.id == sessionScope.user.id) || (TopicInfo.board.boarduser.id == sessionScope.user.id) || (sessionScope.user.usergrade == '0')}"><a href="commonAction.do?method=TopicOrResponsEdit&type=topic&tid=${TopicInfo.id}&rid=">修改编辑</a>&nbsp;&nbsp;<a href="###" onclick="DelPost('${TopicInfo.id}');">删除</a></c:if></c:if></c:if></div>
						<div class="postcontent">
							<div class="c">
							${TopicInfo.content}
							<c:if test="${fn:length(TopicInfo.attlist) > 0}">
								<div class="attachments cl">
								<c:forEach items="${TopicInfo.attlist}" var="attlist"><li><a href="${attlist.path}" target="_blank">${attlist.filename}</a></li></c:forEach>
								</div>
							</c:if>
							</div>
							<c:if test="${parent != null}"><div class="post_p">本帖回复：<a href="commonAction.do?method=TopicResponsInfo&topid=${parent.id}">${parent.title}</a> 由 <a href="commonAction.do?method=ViewUserInfo&uid=${parent.postuser.id}">${parent.postuser.nickname}</a> 发布于 <fmt:formatDate value="${parent.date}" type="both"/></div></c:if>
						</div>
					</div>
					<div id="post_c">
						<div class="bm_h"><h2><a name="alltopid">所有跟帖：</a></h2></div>
						<div>
							<!-- reply post start -->
							<div class="postlist_b">
                                <c:import url="__c.jsp" />
                            
							</div>
							<!-- reply post end -->
						</div>
					</div>
					<div id="post_r">
						<div class="bm_h"><h2><a name="revert">回复本帖：</a></h2></div>
                       	<c:choose><c:when test="${null != sessionScope.user}">
                        <c:if test="${TopicInfo.historical != '1'}">
						<div class="replay_b">
							<form method="post" name="form2" action="commonAction.do?method=TopicResponsSubmit&param=respons&id=${TopicInfo.board.id}&tid=<c:choose><c:when test='${TopicInfo.toppostid == 0}'>${TopicInfo.id}</c:when><c:otherwise>${TopicInfo.toppostid}</c:otherwise></c:choose>&pid=${TopicInfo.id}&paramsort=${TopicInfo.level + 1}&lag=0" enctype="multipart/form-data">
								<div class="frm_row">
									<label>标题: </label><input type="text" name="title" value="回复: ${TopicInfo.title}" style="width:500px;" />
								</div>
                                <div class="frm_row">
									<div class="cl"><label>附　件: </label></div>
									<div id="pho"><input type="button" onClick="addImage()" value="添加附件"></div>
								</div>
								<div class="frm_row">
									<textarea id="fckcontent" name="content" style="display:none"></textarea>
								</div>
							</form>
								<div class="frm_row">
									<button onclick="submitit();">发布</button>
								</div>
						</div>
                        </c:if>
                        </c:when><c:otherwise>
                        <div class="replay_b">
                        	<div class="frm_row">
                            <form name="form5" method="post" action="commonAction.do?method=UserLogin">
                            账号：<input type="text" name="username"> 密码：<input type="password" name="password"> 
                            <button onClick="loginsubmitc();">登陆</button>
                            </form>
                        	</div>
                        </div>
                        </c:otherwise></c:choose>
					</div>
				</div>
			</div>
		</div>
	<jsp:include page="inc/footer.jsp" />

</body>
</HTML>